from lt.vincnetas.melina.webParser import WebParser
from lt.vincnetas.melina.model.document import Document
from google.appengine.ext import db

class DocumentsDao :    
    parser = WebParser()
    maxDocumentsPerDay = 1000

    def getDocuments(self, date, type):
        query = Document.all()
        query.filter("date=", date)
        documents = query.fetch(self.maxDocumentsPerDay, 0)

        print len(documents)                 
        
        if len(documents) != 0:
            return documents                
        
        #documents = self.parser.getDocuments(date)
        #for document in documents:
        #    db.put(document)
            
        return documents
        